package main

import (
	"fmt"
	"sync"
)

/*
https://golang-minibear2333.github.io/2.func-containers/2-4-map/#244-%E8%83%BD%E5%A4%9F%E5%9C%A8%E5%B9%B6%E5%8F%91%E7%8E%AF%E5%A2%83%E4%B8%AD%E4%BD%BF%E7%94%A8%E7%9A%84map
*/
func main() {

	var scene sync.Map
	scene.Store("name", "cm")
	scene.Store("age", 30)

	v, ok := scene.Load("name")
	if ok {
		fmt.Println(v)
	}
	v, ok = scene.Load("age")
	if ok {
		fmt.Println(v)
	}

	scene.Delete("age")

	scene.Range(func(key, value interface{}) bool {
		fmt.Println("key:", key, ",value:", value)
		return true
	})
}
